How Do I Create a Custom Callback for the Java Engine?
The Java Engine ships with powerful extensibility hooks that let you intercept and influence document generation. Custom Callbacks give you programmatic control over how tag select statements are evaluated, allowing you to modify selects or enforce rules at runtime.
Overview
Custom Callbacks are invoked by the Engine each time a tag's select statement is evaluated during document generation. This lets you:
- Rewrite selects dynamically — inspect the incoming select string and return a modified version before the Engine processes it.
- Enforce data-access rules — throw an exception to block generation when a select references data your application deems prohibited (for example, a customer's private address fields).
These are just two examples of what custom callbacks make possible. Because the callback receives the raw select string and can return any replacement value or raise an error, you can build virtually any custom logic around your data access patterns.
How It Works
The Engine looks for a custom callback class whose fully qualified name is set via the callback.class property in your WindwardReports.properties file. When the Engine finds the class it calls the approveSelect() method for every tag select. Your implementation can:
- Return the original select unchanged to let normal processing continue.
- Return a different select string to substitute new logic or data paths.
- Throw an exception to halt generation and surface an error to the caller.
Sample Project
A complete working example is available in the Fluent Code Samples repository: